package com.hhkj.api.order.common.component.supplier;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.hhkj.admin.order.model.dopo.OrderItemPo;
import com.hhkj.admin.order.model.res.OrderItemRes;
import com.hhkj.admin.order.service.extend.OrderItemExtendService;
import com.hhkj.api.order.model.res.ApiOrderIncludeItemRes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * ApiOrderSupplier
 *
 * @author HHKJ-SERVER-ZJ
 * @since 2023/11/7 14:42
 */
@Component
public class ApiOrderSupplier {

    @Autowired
    private OrderItemExtendService itemExtendService;

    /**
     * 给分页信息补充子订单人员列表信息
     *
     * @param orderList 订单列表
     */
//    public void supplierListItemList(List<ApiOrderIncludeItemRes> orderList) {
//        if (CollectionUtil.isEmpty(orderList)) {
//            return;
//        }
//        List<Long> orderIdList
//                = orderList.stream().map(ApiOrderIncludeItemRes::getId)
//                .collect(Collectors.toList());
//        List<OrderItemPo> orderItemPoList = itemExtendService.listPoByOrderIdList(orderIdList);
//
//        Map<Long, List<OrderItemRes>> itemResListByOrderIdMap = orderItemPoList.stream()
//                .map(itemPo -> BeanUtil.toBean(itemPo, OrderItemRes.class))
//                .collect(Collectors.groupingBy(OrderItemRes::getOrderId));
//
//        for (ApiOrderIncludeItemRes orderRes : orderList) {
//            orderRes.setItemList(itemResListByOrderIdMap.get(orderRes.getId()));
//        }
//
//    }
}
